package com.bob.light.activity

import androidx.appcompat.app.AppCompatActivity
import com.bob.light.TuyaHomeSDKHelper
import com.bob.light.toast

open class BackPressedWrapperActivity : AppCompatActivity() {

    private var mBackPressedTime: Long = 0L

    override fun onBackPressed() {
        //获取第一次按键时间
        val mNowTime = System.currentTimeMillis()
        if (mNowTime - mBackPressedTime > 2000) {
            "再次点击退出应用".toast()
            mBackPressedTime = mNowTime
        } else {
            appExit()
        }
    }

    private fun appExit() {
        TuyaHomeSDKHelper.destroy()
        finish()
    }

}